import type { TreeOption } from 'naive-ui';
import { request } from '../request';

/** get list */
export function roleList(params: Api.SystemManage.RoleSearchParams) {
  return request<Api.SystemManage.RoleList>({
    url: '/role/list',
    method: 'post',
    data: params
  });
}

/** save */
export function roleSave(params: Api.SystemManage.RoleSaveParams) {
  return request<boolean>({
    url: '/role/add',
    method: 'post',
    data: params
  });
}

/** save */
export function roleMenuTree() {
  return request<{ menuTree: Array<TreeOption & { type: string }>; allMenuIds: string[] }>({
    url: '/role/menuTree',
    method: 'get'
  });
}

/** update */
export function roleUpdate(params: Api.SystemManage.RoleUpdateParams) {
  return request<boolean>({
    url: '/role/update',
    method: 'post',
    data: params
  });
}

/** del */
export function roleDel(params: { id: string }) {
  return request<boolean>({
    url: '/role/del',
    method: 'post',
    data: params
  });
} /** getMenuIdById */
export function roleGetMenuIdById(params: { id: string }) {
  return request<string[]>({
    url: '/role/getMenuIdById',
    method: 'post',
    data: params
  });
}

/** delBatch */
export function roleDelBatch(params: { ids: Array<string> }) {
  return request<boolean>({
    url: '/role/delBatch',
    method: 'post',
    data: params
  });
}
